package demo.retry;

import demo.annotation.SoutParam;
import demo.utils.DateUtil;
import demo.utils.MathUtil;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

/**
 * @author : GuoFei
 * @date : 2018/12/14 15:36
 */
@Service
@SoutParam()
public class RetryTest {

    static RetryTest retryTest = null;

    public static RetryTest getInstance(){
        if (retryTest == null) {
            retryTest =new RetryTest();
        }
        return retryTest;
    }

    public static void main(String[] args) {
        System.out.println(DateUtil.formatDateTime(new Date(),DateUtil.PATTERN_yyyy_MM_dd_HH_mm_ss_SSS)+Thread.currentThread().getName()+"___"+"nihao");
//        RetryUtil.addRetry(new RetryUtil.RetryObj() {
//            @Override
//            public boolean run() {
//                return test();
//            }
//        },3,1000);

        test(23,32);
    }

    public static boolean test(int arg1 ,int arg2) {
        RetryUtil2.setRetryTimes(2).retry(getInstance(),arg1,arg2);
        System.out.println(arg1+"_"+arg2);
        System.out.println(DateUtil.formatDateTime(new Date(),DateUtil.PATTERN_yyyy_MM_dd_HH_mm_ss_SSS)+Thread.currentThread().getName()+"___"+"text");
        return RandomUtils.nextInt()==0;
    }

//    @SoutParam()
    public void testSout(int num, String name) {
        System.out.println("执行了");
    }
}
